import QtQuick 1.0

Item {
    property bool ended : false;
    
    function onEnd(responseText){
	console.log('resp:'+responseText);
	var data = JSON.parse(responseText);
	console.log('data===>');
	console.log(JSON.stringify(data));
    }
    
    Component.onCompleted: {
       var urlJson = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=%22Pop%20et%20le%20nouveau%20monde%22";
       var xhr = new XMLHttpRequest();
       xhr.onreadystatechange = function(){
	  if(xhr.readyState == xhr.DONE && 200 == xhr.status){
	    ended=true;
	    onEnd(xhr.responseText);
	  }
       }
       
       xhr.open("GET",urlJson);
       xhr.setRequestHeader("Accept","application/json"); 
       console.log('before send');
       xhr.send(null);
       console.log('after send');
       
        
    }  
}
 
